<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Mailer
 *
 * @author bonfiglio
 */
class Mailer extends PHPMailer {

    public function __construct($options = array(), $exceptions = false) {
        parent::__construct($exceptions);
        $this->IsSMTP();                            // telling the class to use SMTP
        $this->Host = "smtp.certinergy.com";        // SMTP server mail.yourdomain.com
        //$this->SMTPDebug = 2;                      // enables SMTP debug information (for testing)
        // 1 = errors and messages
        // 2 = messages only
        $this->SMTPAuth = true;                   // enable SMTP authentication
        $this->Port = 587;
        $this->Host = "smtp.certinergy.com";        // sets the SMTP server mail.yourdomain.com
        $this->Username = "logweb@certinergy.com";    // SMTP account username
        $this->Password = "logweb_2012";              // SMTP account password

        $this->CharSet = "UTF-8";
        if (array_key_exists('from', $options)) {
            foreach ($options['from'] as $name=>$address) {
                $name = is_string($name) ? $name : '';
                $this->SetFrom($address, $name);
                break;
            }
        } else {
            $from_mail = array_key_exists('from_mail', $options) ? $options['from_mail'] : "noreply@certinergy.com";
            $from_name = array_key_exists('from_name', $options) ? $options['from_name'] : "";
            $this->SetFrom($from_mail, $from_name);
        }
        if (array_key_exists('to', $options)) {
            foreach ($options['to'] as $name=>$address) {
                $name = is_string($name) ? $name : '';
                $this->AddAddress($address, $name);
            }
        }
        if (array_key_exists('cc', $options)) {
            foreach ($options['cc'] as $name=>$address) {
                $name = is_string($name) ? $name : '';
                $this->AddCC($address, $name);
            }
        }
        if (array_key_exists('bcc', $options)) {
            foreach ($options['bcc'] as $name=>$address) {
                $name = is_string($name) ? $name : '';
                $this->AddBCC($address, $name);
            }
        }
    }

}

?>
